package ynu.edu.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import ynu.edu.entity.Food;
import ynu.edu.service.FoodService;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/FoodController")
public class FoodController {

    @Autowired
    private FoodService foodService;

    @PostMapping("/listFoodByBusinessId")
    public ResponseEntity<?> listFoodByBusinessId(@RequestBody Food params) {
        log.info("Received listFoodByBusinessId request with params: {}", params);
        List<Food> foods = foodService.listFoodByBusinessId(params.getBusinessId());
        log.info("Found foods: {}", foods);
        return ResponseEntity.ok(foods);
    }

    @PostMapping("/getFoodById")
    public ResponseEntity<?> getFoodById(@RequestBody Food params) {
        log.info("Received getFoodById request with params: {}", params);
        Food food = foodService.getFoodById(params.getFoodId());
        log.info("Found food: {}", food);
        return ResponseEntity.ok(food);
    }
} 